AggregateExec: incremental memory release before streaming merge#19751
Draft
Nachiket-Roy wants to merge 2 commits intoapache:mainfrom
Draft
AggregateExec: incremental memory release before streaming merge#19751Nachiket-Roy wants to merge 2 commits intoapache:mainfrom
Nachiket-Roy wants to merge 2 commits intoapache:mainfrom
Conversation
Contributor
Author
|
cc @2010YOUY01 @EmilyMatt Please go through the PR description Thanks! |
Contributor
|
Can you take a look at the failing tests please? |
Contributor
Author
The failing tests point to an underlying issue in this approach that doesn’t seem fixable with a small change alone and likely needs an architectural decision. I’ve added more context in the PR description. |
Member
Converted to draft |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Which issue does this PR close?
Related to #19679
Related to #19695
Rationale for this change
It was observed that downstream operators (such as
SortExec) can receive extremely largeRecordBatchoutputs fromAggregateExec, violating the implicitbatch_sizeconvention used throughout the physical plan.An initial hypothesis was that normalizing batch sizes at the
AggregateExec->SortExecboundary would be sufficient.However, while implementing and testing this, it became clear that:
GroupedHashAggregateStreamallocates group keys and accumulator state before memory reservation checks are enforcedbatch_size, internal state can exceed memory limitsThis indicates that the issue is not a simple emission bug, but a design boundary between:
batch_sizeas an output convention vs. a hard invariantThis PR aims to:
What changes are included in this PR?
Importantly, this PR does not claim to fully enforce
batch_sizeat all stages, nor does it prevent all oversized intermediate states. Instead, it reduces memory pressure and clarifies current limitations.Are these changes tested?
Yes, but edge cases revealed design limitations rather than simple bugs
The PR is submitted primarily for review and discussion rather than as a final fix.
Are there any user-facing changes?
No.